import React from 'react';
import {useMemo } from 'react';
import ReactDOM from 'react-dom/client';
import { TonConnectUIProvider } from '@tonconnect/ui-react';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

import { Buffer } from 'buffer';
window.Buffer = Buffer;
window.process = window.process || { env: {} }; // 防止 process 未定义


const root = ReactDOM.createRoot(document.getElementById('root'));
export function InnerApp() {
  const manifestUrl = useMemo(() => {
    return new URL('tonconnect-manifest.json', window.location.href).toString();
  }, []);

  return (
    <TonConnectUIProvider manifestUrl={manifestUrl}>
      <App/>
    </TonConnectUIProvider>
  );
}



root.render(
  <React.StrictMode>
    <InnerApp />
  </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
